package com.agileai.bpm.bizmoduler.instance;

import java.util.ArrayList;
import java.util.List;

import com.agileai.domain.DataParam;
import com.agileai.domain.DataRow;
import com.agileai.hotweb.bizmoduler.core.BaseService;

public class WfProcessInstanceManageImpl extends BaseService implements WfProcessInstanceManage{

	public List<DataRow> findInstanceListRecords(DataParam param) {
		String statementId = sqlNameSpace+"."+"queryListRecords";
		List<DataRow> result = this.daoHelper.queryRecords(statementId, param);
		return result;
	}

	public List<DataRow> findInstanceStatRecords(DataParam param) {
		String statementId = sqlNameSpace+"."+"queryStatRecords";
		List<DataRow> result = this.daoHelper.queryRecords(statementId, param);
		return result;
	}

	public int queryInstanceNumber(DataParam param) {
		int result = 0;
		String statementId = sqlNameSpace+"."+"queryInstanceNumber";
		DataRow record = this.daoHelper.getRecord(statementId, param);
		result = record.getInt("INST_NUM");
		return result;
	}

	public List<String> findActiveActivityInstIds(String processInstId) {
		List<String> result = new ArrayList<String>();
		String statementId = sqlNameSpace+"."+"findActiveActivityInstIds";
		DataParam param = new DataParam();
		param.put("WFIP_ID",processInstId);
		List<DataRow> records = this.daoHelper.queryRecords(statementId, param);
		if (records != null){
			for (int i=0;i < records.size();i++){
				DataRow row = records.get(i);
				result.add(row.getString("WFA_ID"));
			}
		}
		return result;
	}
}
